package com.example.androidcomplete0102.ch17;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.example.androidcomplete0102.R;

public class ApplicationTest extends Activity {
	static final String TAG ="APPLICATION";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ch17_applicationtest);
		
		ApplicationEx app = (ApplicationEx)getApplication();
		Toast.makeText(this, "전역정보:"+app.getmMode(), Toast.LENGTH_LONG).show();
	}
	
	public void mOnClick(View v){
		ApplicationEx app = (ApplicationEx)getApplication();
		switch(v.getId()){
		case R.id.ch17_btnbeginner:
			app.setmMode(ApplicationEx.BEGINEER);
			break;
		case R.id.ch17_btnpro:
			app.setmMode(ApplicationEx.PROFESSIONAL);
			break;
		}
		updateNowMode();
	}
	
	private void updateNowMode(){
		TextView tv = (TextView)findViewById(R.id.ch17_mode);
		ApplicationEx app = (ApplicationEx)getApplication();
		
		if(app.getmMode() == ApplicationEx.BEGINEER){
			tv.setText("현재모드: 초보자 모드");
		}else{
			tv.setText("현재모드: 숙련자 모드");
		}
	}
}
